import http from "@/utils/request";

const apiPrefix = "/order";


export async function searchOrderByPage(params) {
  return await http.request({
    params: params,
    url: apiPrefix + '/page',
    method: 'get'
  })
}

export async function downLoadTemplate() {
  window.open(process.env.VUE_APP_API_BASE_URL + 'order/delivery/excel')
}

export async function uploadTemplate(data) {
  return await http.request({
    url: apiPrefix + '/delivery/excel',
    data,
    method: 'post'
  })
}

export async function editDelivery(data) {
  return await http.request({
    data,
    url: apiPrefix + '/delivery',
    method: 'post'
  })
}


export async function searchOrderById(id) {
  return await http.request({
    params: {
      id
    },
    url: apiPrefix + '/id',
    method: 'get'
  })
}

export async function sendOrder(data) {
  return await http.request({
    data,
    url: apiPrefix + '/delivery',
    method: 'post'
  })
}

export async function cancelOrder(id) {
  return await http.request({
    params: {
      orderId: id
    },
    url: apiPrefix + '/cancel',
    method: 'delete'
  })
}

export async function checkCancelOrder(id, state) {
  return await http.request({
    data: {
      id,
      state
    },
    url: apiPrefix + '/check',
    method: 'post'
  })
}